'use strict';
module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.createTable('Apply', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      openId: {
        allowNull: false,
        type: Sequelize.STRING(100),
      },
      nickname: {
        allowNull: false,
        type: Sequelize.STRING(16),
      },
      company: {
        allowNull: false,
        type: Sequelize.STRING(24),
      },
      prefix: {
        allowNull: false,
        type: Sequelize.INTEGER(3),
        defaultValue: 86
      },
      phone: {
        allowNull: false,
        type: Sequelize.CHAR(13),
      },
      brief: {
        allowNull: false,
        type: Sequelize.STRING(255),
      },
      name: {
        allowNull: false,
        type: Sequelize.STRING(16),
      },
      remark: {
        allowNull: false,
        type: Sequelize.STRING(255),
        defaultValue: ''
      },
      status: {
        allowNull: false,
        type: Sequelize.INTEGER(1),
        defaultValue: 0
      },
      type: {
        allowNull: false,
        type: Sequelize.INTEGER(1),
        defaultValue: 0
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      deletedAt: {
        type: Sequelize.DATE
      }
    }, {
      freezeTableName: true,
      charset: 'utf8mb4',
      collate: 'utf8mb4_general_ci',
      indexes: [{
        unique: true,
        fields: ['openId']
      }],
      comment: '申请表',
    });
  },
  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable('Apply');
  }
};